package no.uio.ifi.cop.parse.option;

import java.util.Vector;


class StringOption implements Option{

    String[] options;
    Vector<String> values;

    protected StringOption(String[] options){
        this.options = options;
        values = new Vector<String>();
    }

    public void clear(){
        values.clear();
    }

    public boolean isSet(){
        return values.size() > 0;
    }

    public void add(String arg){
        values.add(arg);
    }

    public String getValue(){
        return values.elementAt(0);
    }

    public String[] getValues(){
        String[] vals = new String[values.size()];
        return values.toArray(vals);
    }

    public String toString(){

        StringBuilder sb = new StringBuilder();

        for(String s : options){
            sb.append(s + " ");
        }

        if ( isSet() ) {
            sb.append(": ");
            for(String v : values){
                sb.append(v+ " ");
            }
        }else{
            sb.append(": (null)");
        }

        return sb.toString();
    }

}
